home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Dreamweaver 3 / Configuration / Inspectors / keywords.js < prev    next >
Encoding:
Text File  |  1999-12-01  |  2.0 KB  |  61 lines

  1.  
  2.  
  3. //form field names:
  4. //Keywords - text field
  5.  
  6. // *********** GLOBAL VARS *****************
  7.  
  8. var helpDoc = MM.HELP_inspKeywords;
  9.  
  10.  
  11. // ******************** API ****************************
  12. function canInspectSelection(){
  13.  
  14.   var metaObj = getSelectedObj();
  15.   return (metaObj.tagName && metaObj.tagName=="META" &&
  16.           metaObj.getTranslatedAttribute("name") && 
  17.           metaObj.getTranslatedAttribute("name").toLowerCase()=="keywords");
  18. }
  19.  
  20. function inspectSelection(){
  21.   var inspectorState = arguments[0],currKeyVal;
  22.   var contentLayer = findObject("contentField");
  23.   var contentCell = contentLayer.getElementsByTagName("TD").item(0);
  24.   var minText= '<textarea name="Keywords" onBlur="setMetaTag()" '
  25.   + 'style="width:350;height:32" rows="2" wrap="virtual"></textarea>'
  26.   var maxText='<textarea name="Keywords" onBlur="setMetaTag()" '
  27.   + 'style="width:350;height:76" rows="4" wrap="virtual"></textarea>';
  28.   //change inspector state if needed
  29.   //the rows=2 and rows=4 check determines whether current state is min or max
  30.   if (inspectorState=="min"&& (findString('rows="4"',contentCell.innerHTML)||contentCell.innerHTML=="")){
  31.     currKeyVal = findObject("Keywords").value;
  32.     contentCell.innerHTML=minText;
  33.     findObject("Keywords").value = currKeyVal;
  34.   }    
  35.   else if (inspectorState=="max" && (findString('rows="2"',contentCell.innerHTML)||contentCell.innerHTML=="")){
  36.     currKeyVal = findObject("Keywords").value; 
  37.     contentCell.innerHTML=maxText; 
  38.     findObject("Keywords").value = currKeyVal;
  39.   }     
  40.   if (getSelectedObj().getAttribute("content"))     
  41.     findObject("Keywords").value= getSelectedObj().getAttribute("content");
  42.   else
  43.     findObject("Keywords").value="";
  44.   showHideTranslated();
  45. }
  46.  
  47. function findString(stringToFind,stringToLookIn){
  48.   if (stringToLookIn.indexOf(stringToFind)==-1)
  49.     return false;
  50.   return true;    
  51. }
  52.  
  53.  
  54. // ******************** LOCAL FUNCTIONS ****************************
  55.  
  56. function setMetaTag(){
  57.   getSelectedObj().setAttribute("content",findObject("Keywords").value);
  58. }
  59.  
  60.  
  61.